package 剑指offer;

import java.util.Stack;

/**
 * @author SunYuHang
 * @date 2023-02-27 18:59
 * @ClassName : 包含min函数的栈  //类名
 */

public class 包含min函数的栈030 {
    Stack<Integer> minStack;
    int min = Integer.MAX_VALUE;
    /** initialize your data structure here. */
    public 包含min函数的栈030() {
        minStack = new Stack<Integer>();
    }

    public void push(int x) {
        minStack.push(min);
        min = x<min?x:min;
        minStack.push(x);
    }

    public void pop() {
        minStack.pop();
        min = minStack.pop();
    }

    public int top() {
        return minStack.peek();

    }

    public int min() {
        return min;
    }
}
